<?php
// +--------------+------------------------+------+-----+---------+----------------+
// | Field        | Type                   | Null | Key | Default | Extra          |
// +--------------+------------------------+------+-----+---------+----------------+
// | id           | int(11)                | NO   | PRI | NULL    | auto_increment |
// | title        | varchar(60)            | YES  |     |         |                |
// | type         | varchar(15)            | YES  |     |         |                |
// | pc_cover_id  | int(11) unsigned       | YES  |     | 0       |                |
// | wap_cover_id | int(11) unsigned       | YES  |     | 0       |                |
// | status       | tinyint(1)             | YES  |     | 0       |                |
// | member_id    | int(11) unsigned       | YES  |     | 0       |                |
// | create_time  | int(11) unsigned       | YES  |     | 0       |                |
// | update_time  | int(11) unsigned       | YES  |     | 0       |                |
// | slug         | varchar(150)           | YES  |     |         |                |
// | link_url     | varchar(250)           | YES  |     |         |                |
// | open_target  | enum('_self','_blank') | YES  |     | _self   |                |
// | sort         | int(11)                | YES  |     | 0       |                |
// +--------------+------------------------+------+-----+---------+----------------+
namespace app\common\validate;

use think\Validate;

class Banner extends Validate
{
    protected $rule = [
        "title" => "require|max:60",
        "type" => "max:15",
        "link_url" => "max:250|url",
        "open_target" => "in:_blank,_self",
        "pc_cover_id" => "gt:0",
        "wap_cover_id" => "egt:0",
        "member_id" => "egt:0",
    ];

    protected $field = [
        "title"  => "标题",
        "type"  => "类型",
        "link_url"  => "链接地址",
        "open_target"  => "打开方式",
        "pc_cover_id"  => "(PC版)图片",
        "wap_cover_id"  => "手机版图片",
        "member_id"  => "编辑管理员",
    ];

    protected $message = [
        "title.require" =>  "标题不能为空",
        "title.max" => "标题长度长度不能超过60个字符",
        "type.require" => "类型不能为空",
        "type.max" => "标题长度长度不能超过15个字符",
        "link_url.url" => "链接地址格式不正确",
        "link_url.max" => "链接地址太长",
        "open_target.in" => "打开方式不正确",
        "pc_cover_id.require" => "图片不能为空",
        "pc_cover_id.gt" => "图片不能为空",
        "wap_cover_id.egt" => "手机版图片不正确",
        "member_id.egt" => "编辑管理员不正确",
    ];

    protected $scene = [
        'home'  =>  ['title','type', 'link_url', 'open_target', 'pc_cover_id', 'member_id'],
        'link'  =>  ['title','type', 'link_url', 'member_id'],
    ];
}